******************************************************************************
SGL Version 2.0 Sample Program Startup Instructions
******************************************************************************

* Using SGL Sample Code with SNASM

  - Starting SNASM

    1) Power up CartDev and the DevSaturn (modified Saturn)
    2) Power up the host PC.
    3) Set the current directory to the desired sample program.
    4) Execute SNASM (snbugsat.exe).
    5) After starting up SNASM, input "1" to select the master CPU.  System
       initialization is complete if the DevSaturn performs the normal Saturn
       bootup sequence (displays SEGA SATURN logo screen and SEGA logo along 
       with license display).
    6) Select "Load COFF with Debug Info" from the File menu to open a dialog
       box.
    7) Select SL.COF and load the file.
    8) The sample program runs when "Run From PC" is selected from the
       Execution menu.
    9) The program stops when "Stop(DMA & Interrupt)" is selected from the
       Execution menu.
   10) Selecting "Quit(No Save)" from the File menu will shell you out to 
       DOS.

  - Viewing C Source Code with the Debugger
  
    1) Use the compile option "-g" if you wish to refer back to the source
       code.  
    2) Select "Mixed" from the Windows menu after loading the COFF file.
    3) Click on the C Source window to activate it.
    4) Select "Go to..." from the Origin menu and input the function you wish
       to see in "Expression Input" (such as "main").  The resulting C source
       is displayed.
    5) Select "Run From PC" from the Execution menu in the C Source window to
       run the sample code.
    6) It is possible to invoke a BREAK on a highlighted line within the C
       Source window.
       a. The F5 key is used as a toggle switch.  The breakpoint is set when
          it is entered once.
       b. The F6 key runs the program and stops at the breakpoint set with
          the F5 key.
       c. Pressing F5 clears the breakpoint.
       d. Pressing F9 runs the program.
       
* Using SGL Sample Programs with SGI Machines

  - Startup
  
    1) Compiling Code
       Enter the make command in the shell to compile code.

    2) Using the Saturn

       a) Running cartdev-server
       
          Assuming that the monitor program uso.bin is located in
          /usr/Cartdev/bin, enter
          
            cartdev-server -m/usr/Cartdev/bin/usobin
            
          to run cartdev-server.

          If
          
            Accept network connection.
            
          is displayed, setup is complete.
          
          A shell is taken up if the method above is used.  If this is
          undesirable, typing

            cartdev-server -m /usr/Cartdev/bin/uso.bin > & /dev/null
  
          will allow you to run cartdev-server in the background.
          
       b) Starting Up the Debugger          
    
          Move to the directory containing the sample program you wish to run
          and type

            cartdev-gdb sl.coff
          
          After gdb starts up, type
          
            target cartdev-server
            
          This requests a connection with the server process. If the
          connection succeeds, the following is displayed:

            Connect to remote cartdev-server.
            Open remote cartdev-server.
            connected
            
       c) Running Programs
       
          When
            
            load sl.coff
          
          is entered, the program is loaded into the Saturn.
          
          Entering
          
            r
            
          runs the program.
          
          
       NOTE: Running Programs that Use CD Functions
       
             The Saturn's security system must be cleared in order to perform
             CD access on write-once disks.  After confirming that
             cartdev-server is not running as a background process, power down
             CartDev and DevSaturn. Insert a Saturn System Disc (key disk) in
             the DevSaturn.  Power up CartDev, and then DevSaturn. Wait until
             "COMPLETE" is displayed in the upper left corner of the screen.
             After that message is displayed, insert the write once disc and
             then startup cartdev-server.

* Viewing Programs and Performing Source Code Debug

  1) Display Program List
  
     Displaying lines 1 to 10:
     
       l 1, 10
       
     Displaying lines 1 to 10 from file foo.c:
     
       l foo.c:1,10
  
  2) Memory Dump
  
     A command called x is available.
     
     The syntax is as follows:
     
       x/nfu addr
         n: number of iterations
         f: output format
         x: hexadecimal
         d: signed decimal
         u: decimal
         o: octal
         t: binary
         c: ASCII character
         u: data length
            b:byte     (1 byte)
            h:short    (2 byte)
            w:long     (4 byte)
            g:long x 2 (8 byte)
     
     For example, to display 256 bytes of data as short (2 byte) in hex, enter
     
       x/128xh 0x060040000
       
  3) Resetting Variables
  
     For example, to set variable a to 125, enter
     
       set var a = 125
       
  4) Displaying Variables
  
       print a
     
     To display a variable at each break, enter
     
       display a
       
     Note: It is possible to use the same format specifications for print and
           display in the same manner as x shown above.
           
  5) Step Execution
  
     step: Run 1 instruction (also includes those within functions).
     next: Run 1 execution module (a function is 1 execution module).
     
  6) Setting Breakpoints
  
       b foo.c:subroutine
     
     To stop at the 10th line of foo.c:
     
       b foo.c:10
       
     Conditional Breaks
     
       To set a break at the function subroutine within foo.c (however only
       when variable x is at 10):

         if foo.c:subroutine if x == 10
         
  7) Setting Watchpoints
  
     A watchpoint is used to monitor whether a specified memory value has been
     modified.

     To see whether the contents at address 0x06004000 has been modified,
     enter

       watch 0x6004000
       
     To see whether the contents of variable x has been modified, enter
     
       watch &x
       
* Using Makefiles and Conditional Compilation

  It is possible to externally control conditional compilations if the DFLAGS
  macro is used within a Makefile.
  
  For example, when making a program like
  
    #ifdef DEBUG
        :
        A
        :
    #else
        :
        B
        :
    #endif
    
  Specifying 
  
    make DFLAGS=-DDEBUG
                  ^^^^^
  
  will enable the compilation of part B if a make occurs for part A.
  
  This is possible since a macro may be changed during the make if a DFLAGS
  macro option is specified.

* Additional Information About Sample Programs Distributed with this Library

  Run the SGL sample programs with the debugger of your choice by creating
  COFF files with a Make file.  In addition, run the programs below according
  to the steps described here.


  1. SGL CD Sample Programs (Directories S_CD1, S_CD2, S_CD3, S_CD4)
  
     1) After setting the SGL TOOL KIT CD-ROM in the Saturn, start up CartDev
        and DevSaturn.
     2) Initialize the system.  Initialization may be the same as the other
        sample programs.
     3) Load each program and run.  Programs S_CD1, S_CD2, and S_CD3 show an
        on-screen status display.  Each program is operating normally if
        "stat: 00000100" is displayed on the screen.
        Although the program will terminate, previous displays may remain on
        the screen depending on the state of the screen display.
        S_CD4 is an audio demo.  The sample is working normally if the sound
        recorded on the SGL TOOL KIT CD_ROM can be played back (use the Audio
        CD Control Panel [Multiplayer] to play back the audio).
        
  2. Stunner/Virtua Gun Sample Program (directory DEMOGUN)
  
     1) Start up the system after connecting a Stunner to the 1P or 2P control
        port of the Saturn.
     2) The following numbers are shown on the screen:

        Player 1 ID =      25 ; Shows a Stunner is present at the 1P port.
               DATA =    FFFF ; Shows switch data.
               X    =     253 ; Shows the X coordinate tracked by the gun.
               Y    =     153 ; Shows the Y coordinate tracked by the gun.
               
        NOTE: Although the upper left of the screen is set as the origin
              point of the XY screen coordinates, (0,0) may not appear on some
              displays even if that area is targeted.  (0,0) is displayed when
              the gun is shot off-screen.
